<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 

class MyCategories {
    
    
    public function get_category_name($categories,$name)
    {
     
       foreach($categories as $category)
       {
         $current_name = $category->name;
         $current_name = str_replace(' ', '-', $current_name);
         $current_name = mb_strtolower($current_name,'UTF-8');
         $current_name = rawurlencode($current_name);
         if($current_name === $name)
         {
                        
            return $category->category_id;
         }
       }
    }
    public function get_subcategory_name($subcategories,$name)
    {
        foreach($subcategories as $subcategory)
       {
         $current_name = $subcategory->name;
         $current_name = str_replace(' ', '-', $current_name);
         $current_name = mb_strtolower($current_name,'UTF-8');
         $current_name = rawurlencode($current_name);
         if($current_name === $name)
         {
                        
            return $subcategory->subcategories_id;
         }
       }
    }
    public function get_brand_name($brands,$name)
    {
        foreach($brands as $brand)
       {
         $current_name = $brand->name;
         $current_name = str_replace(' ', '-', $current_name);
         $current_name = mb_strtolower($current_name,'UTF-8');
         $current_name = rawurlencode($current_name);
         if($current_name === $name)
         {
                        
            return $brand->brand_id;
         }
       }
    }    
}


/* End of file Someclass.php */